package fr.afcepf.iziticket.beans;

import java.util.ArrayList;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;

import fr.afcepf.iziticket.entities.Reservation;
import fr.afcepf.iziticket.entities.Utilisateur;
import fr.afcepf.iziticket.services.ConfirmationCommandeService;

@ManagedBean(name="mbConfirmation")
@SessionScoped
public class ConfirmationCommandeManagedBean {

	private ConfirmationCommandeService service = ConfirmationCommandeService.getService();
	
	@ManagedProperty(value = "#{mbLogin}")
	private LoginManagedBean mbLogin;
	@ManagedProperty(value="#{mbHistorique}")
	private HistoriqueManagedBean mbHistorique;
	private List<Reservation> reservations = new ArrayList<Reservation>();

	public HistoriqueManagedBean getMbHistorique() {
		return mbHistorique;
	}
	public void setMbHistorique(HistoriqueManagedBean mbHistorique) {
		this.mbHistorique = mbHistorique;
	}
	public LoginManagedBean getMbLogin() {
		return mbLogin;
	}
	public void setMbLogin(LoginManagedBean mbLogin) {
		this.mbLogin = mbLogin;
	}
	public List<Reservation> getReservations() {
		return reservations;
	}
	public void setReservations(List<Reservation> reservations) {
		this.reservations = reservations;
	}
		
	public void init(){
		
		reservations.clear();
		Utilisateur client = mbLogin.getUtilisateur();
		int idClient = client.getIdUtilisateur();
		
		service.init(idClient, reservations);
			
	}

}
